package com.fr.report.web.ui;

import com.fr.base.core.html.Tag;
import com.fr.base.core.json.JSONException;
import com.fr.base.core.json.JSONObject;
import com.fr.report.Report;
import com.fr.web.Repository;
import com.fr.web.core.HTMLWriter;
import com.fr.web.core.chwriter.FormCellWriter;

public abstract class Composite extends Widget
{
  public static final String EVENT_AFTERINIT = "afterinit";
  public static final String EVENT_AFTERLOAD = "afterload";

  public abstract Report getReport(Repository paramRepository);

  public Tag getTableTag(Repository paramRepository)
  {
    Report localReport = getReport(paramRepository);
    if (localReport == null)
      return new Tag("div");
    Tag localTag = HTMLWriter.getInstance().writeJSReport(localReport, 0, new FormCellWriter(paramRepository, 0), paramRepository);
    return localTag;
  }

  public String[] supportedEvents()
  {
    return new String[] { "afterinit", "afterload" };
  }

  public String getXType()
  {
    return "composite";
  }

  public boolean isEditor()
  {
    return false;
  }

  public JSONObject createJSONConfig(Object paramObject, Repository paramRepository)
    throws JSONException
  {
    JSONObject localJSONObject = super.createJSONConfig(paramObject, paramRepository);
    localJSONObject.put("html", getTableTag(paramRepository).toHtml());
    return localJSONObject;
  }

  public boolean equals(Object paramObject)
  {
    if ((paramObject == null) || (!(paramObject instanceof Composite)))
      return false;
    return super.equals(paramObject);
  }
}